import {MarketOrderDetailResponse, QueryMarketOrderInMarketResponse} from "../apis/MarketOrderApi";
import {ListDetailPageStackSlicinationStore} from "./ListDetailSliceStackStore";


const marketOrderInMarketPageStackStore = new ListDetailPageStackSlicinationStore<QueryMarketOrderInMarketResponse, MarketOrderDetailResponse, number>(
    detail => ({
        id: detail.id,
        createdDateTime: detail.createdDateTime,
        status: (() => {
            if (!detail.submitDateTime) {
                return "WAIT_SUBMIT"
            } else if (!detail.deliveryDateTime) {
                return "SUBMITTED"
            } else {
                return "DELIVERY"
            }
        })(),
        lastModifiedDateTime: detail.createdDateTime,
        goodsKindAmount: detail.items.length,
        createdBy: detail.createdBy,
    }),
    item => item.id,
    detail => detail.id
)

export default marketOrderInMarketPageStackStore